/*
* pps_bom
*/
package com.pitop.assembly.api;

import com.pitop.assembly.entity.Assembly;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 组件 api请求熔断器
 *
 * @author berton
 */
@FeignClient(value = "pps-cloud-provider", fallback = AssemblyFeignApiImpl.class)
public interface AssemblyFeignApi {
    /**
     * 查询Assembly一个详情信息
     *
     * @param id
     * @param code 编码
     * @return Assembly
     */
    @GetMapping(value = "/assembly/load")
    Assembly load(@RequestParam("id") Long id, @RequestParam("code") String code);

    /**
     * 查询Assembly一个详情信息
     *
     * @param id
     * @param code 编码
     * @return Assembly
     */
    @GetMapping(value = "/assembly/get")
    Assembly get(@RequestParam("id") Long id, @RequestParam("code") String code);

    /**
     * 根据条件id查询Assembly一个详情信息
     *
     * @param id
     * @return Assembly
     */
    @GetMapping(value = "/assembly/load/id/{id}")
    Assembly loadById(@RequestParam("id") Long id);

    /**
     * 根据条件code查询Assembly一个详情信息
     *
     * @param code 编码
     * @return Assembly
     */
    @GetMapping(value = "/assembly/load/code/{code}")
    Assembly loadByCode(@RequestParam("code") String code);

    /**
     * 根据条件code查询Assembly一个详情信息
     *
     * @param name 编码
     * @return Assembly
     */
    @GetMapping(value = "/assembly/load/name/{name}")
    Assembly loadByName(@RequestParam("name") String name);

    /**
     * 根据条件assemblyCode查询Assembly一个详情信息
     *
     * @param assemblyCode 组件代码
     * @return Assembly
     */
    @GetMapping(value = "/assembly/load/assemblyCode/{assemblyCode}")
    Assembly loadByAssemblyCode(@RequestParam("assemblyCode") String assemblyCode);

    /**
     * 根据条件id查询Assembly一个详情信息
     *
     * @param id
     * @return Assembly
     */
    @GetMapping(value = "/assembly/get/id/{id}")
    Assembly getById(@RequestParam("id") Long id);

    /**
     * 根据条件code查询Assembly一个详情信息
     *
     * @param code 编码
     * @return Assembly
     */
    @GetMapping(value = "/assembly/get/code/{code}")
    Assembly getByCode(@RequestParam("code") String code);

    /**
     * 删除Assembly
     */
    @DeleteMapping("/assembly/delete")
    void delete(@RequestParam("id") Long id, @RequestParam("code") String code);


    /**
     * 查询Assembly信息集合
     *
     * @return 分页对象
     */
    @PostMapping(value = "/assembly/list")
    List<Assembly> list(@RequestBody Assembly assembly, @RequestParam("curPage") int curPage, @RequestParam("pageSize") int pageSize);


    /**
     * 根据bom编码查询组件信息
     *
     * @return 分页对象
     */
    @GetMapping(value = "/assembly/listForBom")
    List<Assembly> listForBom(@RequestParam("bomCode") String bomCode, @RequestParam("name") String name, @RequestParam("curPage") int curPage, @RequestParam("pageSize") int pageSize);


    /**
     * 查询Assembly信息集合
     *
     * @return 分页对象
     */
    @GetMapping(value = "/assembly/list/by")
    List<Assembly> listByPk(@RequestParam("id") Long id, @RequestParam("code") String code, @RequestParam("curPage") int curPage, @RequestParam("pageSize") int pageSize);


    /**
     * 统计Assembly信息数量根据主键
     *
     * @return 总条数
     */
    @GetMapping(value = "/assembly/count/by")
    Integer count(@RequestParam("id") Long id, @RequestParam("code") String code);

    /**
     * 统计Assembly信息数量
     *
     * @return 总条数
     */
    @PostMapping(value = "/assembly/count")
    Integer count(@RequestBody Assembly assembly);

    /**
     * 根据bom编码查询组件信息数量
     *
     * @param bomCode bom编码
     * @param name    组件名称
     * @return
     */
    @GetMapping(value = "/assembly/countForBom")
    Integer countForBom(@RequestParam("bomCode") String bomCode, @RequestParam("name") String name);


    /**
     * 创建Assembly
     *
     * @return Assembly
     */
    @PostMapping("/assembly/build")
    Assembly build(@RequestBody Assembly assembly, @RequestParam("account") String account, @RequestParam("code") String code);


    /**
     * 修改Assembly
     *
     * @return Assembly
     */
    @PutMapping("/assembly/modify")
    Assembly modify(@RequestBody Assembly assembly,@RequestParam("account") String account,@RequestParam("accountCode") String accountCode);


    /**
     * 修改Assembly
     *
     * @return Assembly
     */
    @PostMapping("/assembly/addMaterial")
    Assembly addMaterial(@RequestParam("code") String code, @RequestParam("materialCodes") String materialCodes);


    /**
     * 复制组件
     *
     * @param code        组件编码
     * @param account
     * @param accountCode
     * @return Assembly
     */
    @GetMapping("/assembly/copy")
    Assembly copy(@RequestParam("code") String code, @RequestParam("account") String account, @RequestParam("accountCode") String accountCode);


    /**
     * 修改组件状态
     *
     * @return Assembly
     */
    @PutMapping("/assembly/updateState")
    Assembly updateState(@RequestParam("code") String code, @RequestParam("state") String state);


}
